<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('动土作业')" />
	<link rel="stylesheet" href="/libs/mui/css/mui.min.css">
	<link rel="stylesheet" type="text/css" href="/libs/mui/css/app.css" />
	<link rel="stylesheet" type="text/css" href="/libs/mui/css/mui.picker.min.css" />
	<link rel="stylesheet" type="text/css" href="/common/css/form.css">
	<link  rel="stylesheet" type="text/css"  href="/libs/webuploader/webuploader.css"/>
</head>
<body class="up_body">
<div class="mui-content up_form_content">
	<!--表单start-->
	<form class="mui-input-group up_group" id="form">
		<div class="up_gray"></div>
		<div class="up_gray"></div>
		<input th:value="${data.ID}" type="hidden" class="id" name="ID">
		<!--<div class="up_row">-->
			<!--<label><font>*</font>作业申请单位1</label>-->
			<!--<input type="hidden" value="" name="OrganizationID" id="data">-->
			<!--<input type="text" class="icon_more" onclick="selectDeptTree(this)" name="ignore0" bind-name="OrganizationID" placeholder="请选择" id="OrganizationID"  required>-->
			<!--<div class="clear_both"></div>-->
		<!--</div>-->
		<div class="up_row">
			<label><font>*</font>作业申请单位</label>
			<input type="text" th:value="${data.OrganizationName}" id="data" readonly>
			<input type="hidden" th:value="${data.OrganizationID}" name="OrganizationID">
			<div class="clear_both"></div>
		</div>

		<div class="up_row">
			<label><font>*</font>申请人：</label>
			<input type="text" th:value="${data.ApplyUserName}"  readonly>
			<input type="hidden" th:value="${data.ApplyUserID}" name="ApplyUserID">
			<div class="clear_both"></div>
		</div>
		<div class="up_gray"></div>

		<div class="up_row">
			<label><font>*</font>作业单位：</label>
			<!--<input type="hidden" value="" name="WorkOrg">-->
			<input type="text" th:value="${data.WorkOrg}" placeholder="请输入" name="WorkOrg">
			<div class="clear_both"></div>
		</div>



		<div class="up_row">
			<label><font>*</font>作业内容</label>
			<textarea rows="5" th:value="${data.WorkContent}" th:text="${data.WorkContent}" placeholder="请输入" name="WorkContent" required></textarea>
		</div>

		<div class="up_row">
			<label><font>*</font>作业区域/地点：</label>
			<textarea rows="5" th:value="${data.WorkPlace}" th:text="${data.WorkPlace}" placeholder="请输入" name="WorkPlace" required></textarea>
		</div>


		<div class="up_row">
			<label><font>*</font>作业开始时间</label>
			<input type="text" class="date-select icon_more" th:value="${data.BeginDate}" placeholder="请选择" name="BeginDate" required>
			<div class="clear_both"></div>
		</div>
		<div class="up_row">
			<label><font>*</font>作业结束时间</label>
			<input type="text" class="date-select icon_more" th:value="${data.EndDate}" placeholder="请选择" name="EndDate" required>
			<div class="clear_both"></div>
		</div>


		<div class="up_row">
			<label><font>*</font>区域</label>
			<input type="hidden" value="" th:value="${data.FactoryAreaID}" name="FactoryAreaID">
			<input type="text" class="icon_more" onclick="selectAreaTree(this)" name="ignore5" th:value="${data.FactoryAreaName}" bind-name="FactoryAreaID" placeholder="请选择" id="FactoryAreaID"  required>
			<div class="clear_both"></div>
		</div>


		<div class="up_row">
			<label><font>*</font>涉及的其他特殊作业</label>
			<textarea rows="5" th:value="${data.OtherTask}" th:text="${data.OtherTask}" placeholder="请输入" name="OtherTask" required></textarea>
		</div>

		<div class="up_row">
			<label><font>*</font>备注</label>
			<textarea rows="5" th:text="${data.Remark}" placeholder="请输入" name="Remark" required></textarea>
		</div>



		<div class="up_row">
			<label><font>*</font>生产单位负责人</label>
			<input type="hidden" name="FirstUserID" th:value="${data.FirstUserID}"/>
			<input type="text" class="icon_more" onclick="selectUserTree(this)" th:value="${data.FirstUserName}" name="ignore7" bind-name="FirstUserID" placeholder="请选择" id="FirstUserName"  required>
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>

		<div class="up_row">
			<label><font>*</font>安环部负责人</label>
			<input type="hidden" name="SecondUserID" th:value="${data.SecondUserID}"/>
			<input type="text" class="icon_more" onclick="selectUserTree(this)" th:value="${data.SecondUserName}" name="ignore8" bind-name="SecondUserID" placeholder="请选择" id="SecondUserName"  required>
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>

		<div class="up_row" id="ThirdUsershow" >
			<label><font>*</font>设备部负责人</label>
			<input type="hidden" name="ThirdUserID" th:value="${data.ThirdUserID}" />
			<input type="text" class="icon_more" onclick="selectUserTree(this)" th:value="${data.ThirdUserName}" name="ignore8" bind-name="ThirdUserID" placeholder="请选择" id="ThirdUserID"  required>
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>


		<div class="up_gray"></div>
		<!--表单end-->
		<div class="up_button">
			<input type="button" id="submit" class="up_button_all" value="提交" />
			<!--<input type="button" class="up_button_right" value="保存" /></div>-->
		<div class="clear_both"></div>
		</div>

	</form>
</div>

</body>
<th:block th:include="include :: footer" />
<script src="/libs/mui/js/mui.min.js"></script>
<script src="/libs/mui/js/mui.picker.min.js"></script>
<script src="/libs/webuploader/webuploader.nolog.js"></script>
<script src="/common/js/form.js"></script>
<script>
	//回显内容
//	$("#OrganizationID").val($.userOperate.deptName());
//	$("#ApplyUserID").val($.userOperate.userName());
//	$("[name=OrganizationID]").val($.userOperate.deptId().replace(/\b(0+)/gi,""));
//	$("[name=ApplyUserID]").val($.userOperate.userId());


    /**
	 * 数据校验
     */
    $("#form").validate({
        focusCleanup: true
    });

    document.getElementsByTagName("input").oninput = function () {
		console.log(111);
    };


	//提交
	$(".up_button_all").click(function(){
        $("[name=Status]").val("0");
	    console.log($.common.serializeNotNull()+"&entityName=DTEarthTask&opName=Apply&userId="+$.userOperate.userId());
	    var data = $("form").serialize()+"&entityName=DTEarthTask&opName=Apply&userId="+$.userOperate.userId();
	    console.log(data);
	    if($.validate.form()){
            $.ajax({
                url:ctx+"/public/Save",
                type:"post",
                data:data,
                dataType:"json",
                success:function (obj) {
                    if(obj.statusCode==0){
                        location.href =  "/dangerous/index/?openId="+$.userOperate.openId();
                    }else{
                        alert(obj.statusMsg);
                    }
                }
            })
		}
	});
    //保存
    $(".up_button_right").click(function(){
        $("[name=Status]").val("0");
//        if ($.validate.form()) {
//            $.ajax({
//                async:false,
//                url:ctx+"/public/Save",
//                type:"post",
//                data:$("form").serialize()+"&entityName=DTFireTask&opName=Edit&userId="+$.userOperate.userId(),
//                dataType:"json",
//                success:function (obj) {
//                    if(obj.statusCode==0){
//                        location.href = "/dangerous/index";
//                    }else{
//                        alert(obj.statusMsg);
//                    }
//                }
//            })
//        }
    });

    // 初始化Web Uploader
    var uploader = WebUploader.create({
        // 选完文件后，是否自动上传。
        auto: true,

        // 文件接收服务端。
        server: ctx + '/public/UpoladFiles',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker',

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    //初始化图片上传 事件
    uploaderInit(uploader);
    //删除图片
    $(document).on("click",".file_close",function(){
        var fileDiv = $(this).parent();
        var fileId = fileDiv.attr("id");
        var imageIds = $("#imageIds").val();
        $("#imageIds").val(imagesIdsReplace(imageIds,fileDiv));
        fileDiv.remove();
        uploader.removeFile(fileId);
    });
</script>
</html>
